<!--
/********************************************************************************
 #                          OpenWebGlobe Version 1.x                            #
 #                              (c) 2010-2015 by                                #
 #           University of Applied Sciences Northwestern Switzerland            #
 #                     Institute of Geomatics Engineering                       #
 #                           martin.christen@fhnw.ch                            #
 ********************************************************************************
 *     Licensed under MIT License. Read the file LICENSE for more information   *
 *******************************************************************************/
                      Hello World: Creating a virtual globe
		                DEBUG VERSION
*******************************************************************************/
-->
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1">

<script type="text/javascript" src="../../../external/closure-library/closure/goog/base.js"></script>
<script type="text/javascript" src="../../../compiled/deps.js"></script>
<script type="text/javascript">goog.require('owg.OpenWebGlobe');</script>

<script type="text/javascript">

//------------------------------------------------------------------------------
// called every frame:
function OnRender(context)
{
   ogSetTextColor(context, 0,1,0);
   ogDrawText(context, "Hello World", 0, 20);
}
//------------------------------------------------------------------------------

function OnMouseDown(context, button, mx, my)
{
   var scene = ogGetScene(context);
	var world = ogGetWorld(scene);
	
	var result = ogPickGlobe(scene, mx, my);
	/*if (result[0])
	{
		alert("hit: "+ result[1]+ ", " + result[2] + ", " + result[3]);
	}*/
}

function main()
{
	// (1) Specify where artwork is located.
	// This must be a directory and end with "/". It is recommended
	// to have it relative to this html (to prevent cross origin issues).
	ogSetArtworkDirectory("../../../art/");
	
   // (2) create an OpenWebGlobe context using canvas
   // first parameter is canvas-id and second is "fullscreen"
   var ctx = ogCreateContextFromCanvas("canvas", true);
   
   // (3) Create a virtual globe
   var globe = ogCreateGlobe(ctx);
   
   // (4) Add image and an elevation layers
   var imgBlueMarble500 = 
   {
      url     : ["http://www.openwebglobe.org/data/img"],
      layer   : "World500",
      service : "i3d"
   };
   
   var imgLandsat_CH = 
   {
      url     : ["http://www.openwebglobe.org/data/img"],
      layer   : "LandsatCH",
      /*transparency : 0.5,*/
      service : "i3d"
   };
   
   var elvSRTM_CH = 
   {
      url     : ["http://www.openwebglobe.org/data/elv"],
      layer   : "SRTM",
      service : "i3d"
   };
   
   ogAddImageLayer(globe, imgBlueMarble500);
   ogAddImageLayer(globe, imgLandsat_CH);
   ogAddElevationLayer(globe, elvSRTM_CH);
	
	//------------ Create a POI with default style -----------------------------------
	var scene = ogGetScene(ctx);
	
	var PoiDefinition = 
	{
		text 		: 	"Hello World! 世界你好",
		position :  [7.66, 46.13, 6000],
		size 		: 	50
	};
	
	var poi = ogCreatePOI(scene, PoiDefinition);
	//---------------------------------------------------------------------------

   // (5) Set the "Render-Callback" function.
   // The callback function will be called everytime a frame is drawn.
   ogSetRenderFunction(ctx, OnRender);
	ogSetMouseDownFunction(ctx, OnMouseDown);
   
   // (6) Set the background color
   ogSetBackgroundColor(ctx, 0.2,0.2,0.7,1);

}
//------------------------------------------------------------------------------
   
</script>

</head>
<body onload="main()" style="padding:0px; margin:0px; overflow:hidden;">
   <canvas id="canvas"></canvas>          
</body>
</html>
